var Debug = require('debug');

const debug = Debug('icecreamback:model')

var models = {}

const setModel = (name, model) => {
  debug('set model '+name)
  models[name] = model
}

const getModel = (name) => {
  if (models[name] === undefined) throw new Error('model '+name+' not found')
  return models[name]
}

const list = () => Object.assign({}, models)

const clear = () => models = {}

exports.setModel = setModel
exports.getModel = getModel
exports.list =list
exports.clear =clear